//=============================================================================

#ifndef ASERVER_H
  #define ASERVER_H

//=============================================================================

#include "aNet.h"

//=============================================================================

enum asrRet
{
  SRV_DONE = -128,
  SRV_SOCKLISTENERROR,
};

//=============================================================================

class aClientData
{
  public:
    aClientData()
    {
      memset(&addr, 0, sizeof(addr));
      sock = 0;
    }
    ~aClientData()
    {
    }

  public:
    sockaddr addr;
    SOCKET sock;
};

//=============================================================================

class aServer : public aNet
{
  public:
    inline void asSetMaxConnections(unsigned long n) {maxCon = n;}
    inline unsigned long asGetMaxConnections() {return maxCon;}

  private:
    inline asrRet asSetListen() {if (listen(sock, SOMAXCONN) == SOCKET_ERROR) return SRV_SOCKLISTENERROR; return SRV_DONE;}

  public:
    aServer();
    aServer(u_short pn);
      void asStartServerAcception();
      antRet anAnalyzePacket(SOCKET s, const aPacket& p);
    ~aServer();

  private:
    unsigned long maxCon;
    aList<aClientData> clients;
};

//=============================================================================

#endif

//=============================================================================
